import { useLoader } from "@react-three/fiber";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import { useTrimesh } from "@react-three/cannon";
import { useRef } from "react";

const Ramp = () => {
  const result = useLoader(GLTFLoader, "models/ramp.glb");

  const geometry = result.scene.children[0].geometry;
  const vertices = geometry.attributes.position.array;
  const indices = geometry.index.array;

  const [ref] = useTrimesh(() => ({
    args: [vertices, indices],
    mass: 0,
    type: "Static"
  }), useRef(null));
};

export default Ramp;